package com.sky.mapper;

import com.sky.Entity.Employee;
import com.sky.annotation.AutoFill;
import com.sky.emumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("select * from employee where username=#{username}")
    Employee selectByUserName(String username);

    //    private Long id;
    //    private String name;
    //    private String username;
    //    private String password;
    //    private String phone;
    //    private String sex;
    //    private String idNumber;
    //    private Integer status;
    //    private String create_time;
    //    private String update_time;
    //    private Long create_user;
    //    private Long update_user;

    @Insert("insert into employee(name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) " +
            "values (#{name}" +
            ",#{username}" +
            ",#{password}" +
            ",#{phone}" +
            ",#{sex}" +
            ",#{idNumber}" +
            ",#{status}" +
            ",#{createTime}" +
            ",#{updateTime}" +
            ",#{createUser}" +
            ",#{updateUser}" +
            ")")
    @AutoFill(OperationType.INSERT)
    int add(Employee employee);

    List<Employee> query(String name, int startIndex, int pageSize);

    long selectCount(String name);


    @AutoFill(OperationType.UPDATE)
    int updateStatus(Employee employee);

    @Select("select * from employee where id=#{id}")
    Employee queryById(Long id);
}
